package com.example.xposed;

import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Binder;
import android.os.IBinder;

public class LocationService extends Service {
    public LocationService() {
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        sendLocation();
        return super.onStartCommand(intent, flags, startId);
    }

    private void sendLocation() {
        SharedPreferences sp = getSharedPreferences("location", MODE_PRIVATE);
        Intent intent = new Intent(UseGps.action);
        intent.putExtra("GPSLatitude", Double.valueOf(sp.getString("GPSLatitude", "0")));
        intent.putExtra("GPSLongitude", Double.valueOf(sp.getString("GPSLongitude", "0")));
        sendBroadcast(intent);
    }

    @Override
    public IBinder onBind(Intent intent) {
        return new Binder();
    }
}